home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-src / doc / building.doc next >
Text File  |  1999-01-01  |  6KB  |  190 lines

  1. vbcc - C compiler (c) in 1995-99 by Volker Barthelmann
  2.  
  3.  
  4. INTRODUCTION
  5.  
  6.     vbcc is a free portable and retargetable ANSI C compiler.
  7.     It is split into a target independant and a target dependant part and
  8.     supports emulating datatypes of the target machine on any other machine
  9.     so that it is possible to e.g. make a crosscompiler for a 64bit machine
  10.     on a 32bit machine.
  11.  
  12.     This document only deals with building vbcc from the source.
  13.     Be sure to read all the documents for your machine.
  14.  
  15.  
  16. LEGAL
  17.  
  18.     vbcc is (c) in 1995-99 by Volker Barthelmann. The builtin preprocessor
  19.     (consisting of the files preproc.c and vbpp.h) is written and (c) by
  20.     Thorsten Schaaps. All other code is (c) by Volker Barthelmann.
  21.     vbcc may be freely redistributed as long as no modifications are made
  22.     and nothing is charged for it.
  23.     Non-commercial usage of vbcc is allowed without any restrictions.
  24.     Commercial usage needs my written consent.
  25.  
  26.     Sending me money, gifts, postcards etc. would of course be very nice
  27.     and may encourage further development of vbcc, but is not legally or
  28.     morally necessary to use vbcc.
  29.  
  30.  
  31. DIRECTORY-STRUCTURE
  32.  
  33.     The vbcc-directory contains the following important files and
  34.     directories:
  35.  
  36.     vbcc/                   The main directory.
  37.     vbcc/Makefile           The Makefile used to build vbcc.
  38.     vbcc/frontend/          Directory containing the source to vc.
  39.     vbcc/vcpp/              Directory containing source to vcpp.
  40.     vbcc/vsc/               Directory containing source to vsc.
  41.     vbcc/machines/target/   Directory for <target>.
  42.     vbcc/bin/               Directory the executables will be placed in.
  43.  
  44.     All compiling is done from the main directory.
  45.     The preprocessor vcpp and the frontend vc are not target-dependant
  46.     and therefore only one version of them is created.
  47.  
  48.     Every available target has at least one subdirectory with its name in
  49.     vbcc/ and contains at least the files machine.h, machine.c and
  50.     machine.dt. Target-specific object-files will also be stored in that
  51.     directory.
  52.  
  53.     The executables will be placed in vbcc/bin/. The main compiler will
  54.     be called vbcc<target>.
  55.  
  56.  
  57. ADAPTING THE MAKEFILE
  58.  
  59.     Before building anything you have to insert correct values for CC, NCC,
  60.     LDFLAGS and NLDFLAGS in the Makefile.
  61.  
  62.     CC       Here you have to insert a command that invokes an ANSI C
  63.              compiler you want to use to build vbcc. It must support
  64.              -D, -I, -c and -o the same like e.g. vc or gcc.
  65.              Additional options should also be inserted here. E.g. if you
  66.              are compiling for the Amiga with vbcc you should add -DAMIGA.
  67.  
  68.     LDFLAGS  Here you have to add options which are necessary for linking.
  69.              E.g. some compilers need special libraries for floating-point.
  70.  
  71.     An example for the Amiga using vbcc would be:
  72.  
  73.       CC = vbcc://bin/vc -DAMIGA
  74.       LDFLAGS = vbcc:libsrc/stdlib/newmalloc.o -lmieee -lextra
  75.  
  76.     (newmalloc.o is just linked for performance and -lextra is needed
  77.     because vcpp unfortunately uses certain non-ANSI-functions.)
  78.  
  79.     An example for a typical Unix-installation would be:
  80.  
  81.       CC = cc
  82.       LDFLAGS = -lm
  83.  
  84.     NCC and NLDFLAGS are similar to CC and LDFLAGS but they must always
  85.     describe a native compiler, i.e. Programs compiled with NCC/NLDFLAGS
  86.     must be executable on the host system. This is needed because during
  87.     the build programs may have to be executed on the host.
  88.  
  89.  
  90. BUILDING vc
  91.  
  92.     Type:
  93.  
  94.       make bin/vc
  95.  
  96.  
  97. BUILDING vcpp
  98.  
  99.     Type:
  100.  
  101.       make bin/vcpp
  102.  
  103.  
  104. BUILDING vsc
  105.  
  106.     Type:
  107.  
  108.       make TARGET=<target> bin/vsc<target>
  109.  
  110.     E.g.:
  111.  
  112.       make TARGET=alpha bin/vscalpha
  113.  
  114.     Omit this step if there is no file machines/<target>/schedule.c.
  115.  
  116.  
  117. BUILDING vbcc
  118.  
  119.     Type:
  120.  
  121.       make TARGET=<target> bin/vbcc<target>
  122.  
  123.     E.g.:
  124.  
  125.       make TARGET=alpha bin/vbccalpha
  126.  
  127.     During the build the program dtgen will be generated and executed on
  128.     the host-system. First it will ask you whether you are building a
  129.     cross-compiler.
  130.  
  131.     Answer 'y' only if you are building a cross-compiler (i.e. a compiler
  132.     which does not produce code for the same machine it it running on).
  133.  
  134.     Note that it does _not_ matter if you are cross-building a compiler,
  135.     i.e. if you are running on system A and building a B->B compiler
  136.     by using an A->B compiler then you can answer 'n'.
  137.  
  138.     If you answered 'y' you will be asked if your system/compiler offers
  139.     certain datatypes. This refers to the compiler you described with
  140.     CC in the Makefile.
  141.     E.g. if CC is an A->B cross-compiler you have to answer the questions
  142.     according to B.
  143.     To each question answer 'y' or 'n' depending if such a datatype is
  144.     available on that compiler. If you answered 'y' you have to type in
  145.     the name of that type on the compiler (e.g. "signed int", "unsigned
  146.     char" etc.).
  147.     If there are not enough datatypes available to build vbcc an error
  148.     message will be printed and the build aborts.
  149.  
  150.  
  151. CONFIGURING
  152.  
  153.     See vc.doc, vsc<target>.doc and vbcc<target>.doc for information on
  154.     how to create the necessary config-files.
  155.  
  156.  
  157. BUILDING CROSS-COMPILERS
  158.  
  159.     As there is often confusion when it comes to cross-building compilers
  160.     or building cross-compilers, here is what has to be done to cross-build
  161.     a B->C cross-compiler on system A with only a native A->A compiler
  162.     available.
  163.  
  164.     This is done by first building an A->B compiler and then cross-building
  165.     the B->C compiler using the A->B compiler.
  166.  
  167.     For the first step you use the A->A compiler for CC as well as NCC.
  168.     Now you type:
  169.  
  170.       make bin/vc
  171.       make bin/vcpp
  172.       make TARGET=B bin/vscB   # omit if there is no machines/B/schedule.c
  173.       make TARGET=B bin/vbccB
  174.  
  175.     The questions about datatypes are answered according to A.
  176.     Then you should write a vc.config for the vbccB cross-compiler.
  177.  
  178.     Now create a second directory containing all the sources to vbcc and
  179.     set CC/LDFLAGS to vc using the config-file for vbccB and NCC/NLDFLAGS
  180.     to the A->A compiler. Type:
  181.  
  182.       make bin/vc
  183.       make bin/vcpp
  184.       make TARGET=C bin/vscC   # omit if there is no machines/C/schedule.c
  185.       make TARGET=C bin/vbccC
  186.  
  187.  
  188. Volker Barthelmann                                      volker@vb.franken.de
  189.  
  190.